import { createRouter, createWebHistory } from 'vue-router';

// function isLogin(){
//   const isLogin = localStorage.getItem('isLogin');
//   return isLogin === 'true';
// }

const routes = [
  {
    path: '/',
    component: () => import('../views/mobile/Home.vue'),
    redirect: {name: 'main'},
  },
  {
    path: '/mobile',
    component: () => import('../views/mobile/Home.vue'),
    redirect: {name: 'main'},
    children:[
      {
        path: 'main',
        name: 'main',
        component: () => import('../views/mobile/main.vue')
      },
      {
        path: 'class',
        name: 'class',
        component:() => import('../views/mobile/class.vue')
      },
      {
        path: 'shop',
        name: 'shop',
        component:() => import('../views/mobile/shop.vue')
      },
      {
        path: 'collect',
        name: 'collect',
        component:() => import('../views/mobile/collect.vue')
      },
      {
        path: 'mine',
        name: 'mine',
        component:() => import('../views/mobile/mine.vue'),
        // redirect: {name: 'note'},
        // // beforeEnter: () => {
        // //   if(isLogin()) {
        // //     return '/mobile/mine';
        // //   }else{
        // //     return '/login';
        // //   }
        // // },
        // children:[
        //   {path: 'note', name:'note', component:() => import('../views/mobile/note.vue')},
        //   {path: 'cookbook', name:'cookbook', component:() => import('../views/mobile/cookbook.vue')}
        // ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: ()=> import('../views/mobile/Login.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: ()=> import('../views/mobile/Register.vue')
  },
  {
    path: '/purchaseList',
    name: 'purchaseList',
    component: ()=> import('../views/mobile/purchaseList.vue')
  },{
    path: '/follow',
    name: 'follow',
    component: () => import('../views/mobile/follow.vue')
  },{
    path: '/detail/:cook_book_id',
    name: 'detail',
    component: () => import('../component/mainDetail.vue')
  },
  {
    path: '/shopDetail/:commodity_id',
    name: 'shopDetail',
    component: () => import('../component/shopDetail.vue')
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
